"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
// 类型推断
// 从赋值的类型中推断出来  类型从右向左推断
var foo = 1; // number
var bar = 'smd'; // string
// 通过return 推断返回值的类型 (底部流出) 
function add(a, b) {
    return a + b;
}
var sum = function (a, b) {
    return a + b;
};
var person = {
    name: 'string',
    age: 18
};
var name = person.name, age = person.age; // name: string   age: number
var defaultprops = {
    name: 'smd',
    age: 18
};
var prop = __assign(__assign({}, defaultprops), { home: 'bj' });
/**
type Props = {
    home: string;
    name?: string | undefined;
    age?: number | undefined;
}
 */
// number + any = any
function addOne(a) {
    return a + 1;
}
function sum3(a, b) {
    return a + addOne(b);
}
var s3 = sum3(1, 3); // let s3: any
var p1 = {
    name: 'xxx',
    fly: function () { },
    talk: function () { }
};
function mixin(one, two) {
    var rest = {}; // 将rest定义为T和U的交集类型
    for (var key in one)
        rest[key] = one[key]; // 赋值时将rest断言成T类型
    for (var key in two)
        rest[key] = two[key]; // 赋值时将rest断言成U类型
    return rest;
}
var x = mixin({ name: 'smd' }, { age: 18 });
var p5 = {
    name: 'qd'
};
